<!DOCTYPE html>
<html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-0 vector-toc-not-available vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-0 vector-feature-night-mode-enabled skin-theme-clientpref-os vector-sticky-header-enabled" lang="fr" dir="ltr"><head>
<meta charset="UTF-8">
<title>Stackless Python</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="./_res_/favicon.png">
<link rel="canonical" href="https://fr.wikipedia.org/wiki/Stackless_Python"> <link href="./_mw_/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.wikimediamessages.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./_mw_/site.styles.css">
<link rel="stylesheet" type="text/css" href="./_mw_/noscript.css">
<link rel="stylesheet" type="text/css" href="./_res_/footer.css">
<link rel="stylesheet" type="text/css" href="./_res_/vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Stackless_Python rootpage-Stackless_Python skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">Stackless Python</span></h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="contentSub">
<div id="mw-content-subtitle"></div>
</div>
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="fr" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="fr" dir="ltr"><div class="infobox_v3 infobox infobox--frwiki noarchive" style="width:260px">
<div class="entete icon informatique" style="color: #000000;"><style data-mw-deduplicate="TemplateStyles:r228712691">
/* start https://fr.wikipedia.org/ */
.mw-parser-output .entete.informatique{background-image:url("./_mw_/Picto.nfo.png")}
/* end https://fr.wikipedia.org/ */
</style>
<div>Stackless Python</div>
</div>
<p class="mw-empty-elt">
</p>
<table><caption style="color:#000000;">Informations</caption>
<tbody><tr>
<th scope="row"><a href="D%C3%A9p%C3%B4t_(informatique)" title="Dépôt (informatique)">Dépôt</a></th>
<td>
<span class="wd_p1324"><a rel="nofollow" class="external text" href="https://github.com/stackless-dev/stackless">github.com/stackless-dev/stackless</a></span></td>
</tr>
<tr>
<th scope="row"> <a href="Langage_de_programmation" title="Langage de programmation">Écrit en</a>
</th>
<td>
<span class="wd_p277"><a href="Python_(langage)" title="Python (langage)">Python</a> et <a href="C_(langage)" title="C (langage)">C</a></span></td>
</tr>
<tr>
<th scope="row"><a href="Syst%C3%A8me_d'exploitation" title="Système d'exploitation">Système d'exploitation</a></th>
<td>
<span class="wd_p306"><a href="Linux" title="Linux">Linux</a></span></td>
</tr>
<tr>
<th scope="row"> Type
</th>
<td>
<span class="wd_p31">Implémentation d'un langage de programmation <small>(<a href="https://en.wikipedia.org/wiki/Programming_language_implementation" class="extiw external" title="en:Programming language implementation"><span class="indicateur-langue" title="Article sur Wikipédia en anglais">en</span></a>)</small><br>Dialecte <small>(<a href="https://en.wikipedia.org/wiki/Dialect_(computing)" class="extiw external" title="en:Dialect (computing)"><span class="indicateur-langue" title="Article sur Wikipédia en anglais">en</span></a>)</small><br><a href="Interpr%C3%A8te_(informatique)" title="Interprète (informatique)">Interprète</a></span></td>
</tr>
<tr>
<th scope="row"><a href="Licence_de_logiciel" title="Licence de logiciel">Licence</a></th>
<td>
<span class="wd_p275"><a href="Python_Software_Foundation_License" title="Python Software Foundation License">Python Software Foundation License</a></span></td>
</tr>
<tr>
<th scope="row"><a href="Site_web" title="Site web">Site web</a></th>
<td>
<span class="wd_p856"><a rel="nofollow" class="external text" href="https://github.com/stackless-dev/stackless/wiki">github.com/stackless-dev/stackless/wiki</a></span></td>
</tr>
</tbody></table>
<p class="mw-empty-elt">
</p>
</div>
<p><b>Stackless Python</b> est une implémentation du langage <a href="Python_(langage)" title="Python (langage)">Python</a>, nommée ainsi car elle vise à éliminer l'utilisation de la <a href="Pile_(informatique)" title="Pile (informatique)">pile</a> du langage <a href="C_(langage)" title="C (langage)">C</a>. Le langage supporte les <a href="Continuation_(informatique)" title="Continuation (informatique)">continuations</a>, les <a href="G%C3%A9n%C3%A9rateur_(informatique)" title="Générateur (informatique)">générateurs</a>, les microthreads et les <a href="Coroutine" title="Coroutine">coroutines</a>.
</p><p>À cause du nombre considérable de changements dans le <a href="Code_source" title="Code source">code source</a>, Stackless Python ne peut pas être installé par-dessus une installation préexistante de Python en tant qu'extension ou <a href="Biblioth%C3%A8que_logicielle" title="Bibliothèque logicielle">bibliothèque</a>. Au contraire, il est une distribution Python complète en elle-même. La plupart des fonctions de Stackless Python ont également été implémentées dans <a href="PyPy" title="PyPy">PyPy</a>, un interprète Python en Python.
</p><p>Stackless Python est énormément utilisé dans l'implémentation d'<a href="Eve_Online" title="Eve Online">Eve Online</a>, un <a href="Jeu_en_ligne_massivement_multijoueur" title="Jeu en ligne massivement multijoueur">jeu en ligne massivement multijoueur</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Concevoir">Concevoir</h2></div>
<p>Avec Stackless Python, un programme en cours d'exécution est divisé en microthreads qui sont gérés par l'interpréteur de langage lui-même, et non par le <a href="Noyau_de_syst%C3%A8me_d'exploitation" title="Noyau de système d'exploitation">noyau du système d'exploitation</a>. Les microthreads gèrent l'exécution de différentes sous-tâches dans un programme sur le même cœur de processeur. Ainsi, ils constituent une alternative à la programmation asynchrone basée sur les événements et évitent également la surcharge liée à l'utilisation de threads séparés pour les programmes monocœur (car aucune commutation de mode entre le mode utilisateur et le mode noyau ne doit être effectuée, de sorte que l'utilisation du processeur peut être réduite)<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>.
</p><p>Bien que les microthreads facilitent l'exécution de sous-tâches sur un seul cœur, Stackless Python ne supprime pas le Global Interpreter Lock de CPython, et n'utilise pas non plus plusieurs threads et/ou processus. Il n'autorise donc que le multitâche coopératif sur un processeur partagé et non le parallélisme (la préemption n'était pas disponible à l'origine mais est maintenant sous une forme<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>). Pour utiliser plusieurs cœurs de processeur, il faudrait toujours créer un système de communication interprocessus au-dessus des processus Python Stackless.
</p><p>En raison du nombre considérable de modifications dans la source, Stackless Python ne peut pas être installé sur une installation Python préexistante en tant qu'extension ou bibliothèque. Il s'agit plutôt d'une distribution Python complète en soi. La majorité des fonctionnalités de Stackless ont également été implémentées dans PyPy, un interpréteur Python auto-hébergé et un compilateur JIT<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Utilisation">Utilisation</h2></div>
<p>Bien que l'ensemble Stackless soit une distribution distincte, sa fonctionnalité de commutation a été empaquetée avec succès sous la forme d'une extension <a href="CPython" title="CPython">CPython</a> appelée greenlet<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>. Il est utilisé par un certain nombre de bibliothèques (par exemple gevent<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>) pour fournir une solution de threading verte pour CPython. Python a depuis reçu une solution native pour les threads verts : wait/async.
</p><p>Stackless est largement utilisé dans la mise en œuvre du jeu en ligne massivement multijoueur Eve Online ainsi que dans la plate-forme de messagerie d'IronPort.
</p>
<div class="mw-heading mw-heading2"><h2 id="Notes_et_références"><span id="Notes_et_r.C3.A9f.C3.A9rences"></span>Notes et références</h2></div>
<div class="references-small decimal" style=""><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a> </span><span class="reference-text"><span class="ouvrage" id="Sweigart2015"><span class="ouvrage" id="Al_Sweigart2015">Al Sweigart, <cite class="italique">Automate the Boring Stuff with Python</cite>, No Starch Press, <time>2015</time> <small style="line-height:1em;">(<a rel="nofollow" class="external text" href="https://python.engineering/automate-the-boring-stuff-with-python//ISBN=978-1593275990">lire en ligne</a>)</small><span class="Z3988" title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Automate+the+Boring+Stuff+with+Python&rft.pub=No+Starch+Press&rft.aulast=Sweigart&rft.aufirst=Al&rft.date=2015&rft_id=https%3A%2F%2Fpython.engineering%2Fautomate-the-boring-stuff-with-python%2F%2FISBN%3D978-1593275990&rfr_id=info%3Asid%2Ffr.wikipedia.org%3AStackless+Python"></span></span></span></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a> </span><span class="reference-text"><span class="ouvrage">« <a rel="nofollow" class="external text" href="https://bitbucket.org/stackless-dev/stackless/wiki/Home"><cite style="font-style:normal;">About Stackless</cite></a> » <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2016-08-26" data-sort-value="2016-08-26">26 août 2016</time>)</small></span> : <span class="citation">« a round robin scheduler is built in. It can be used to schedule tasklets either cooperatively or preemptively. »</span></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a> </span><span class="reference-text"><span class="ouvrage">« <a rel="nofollow" class="external text" href="http://pypy.readthedocs.org/en/latest/stackless.html"><cite style="font-style:normal;">Application-level Stackless features — PyPy documentation</cite></a> », sur <span class="italique">pypy.readthedocs.org</span></span></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a> </span><span class="reference-text"><span class="ouvrage">« <a rel="nofollow" class="external text" href="http://greenlet.readthedocs.org/en/latest/"><cite style="font-style:normal;">greenlet: Lightweight concurrent programming — greenlet 0.4.0 documentation</cite></a> », sur <span class="italique">greenlet.readthedocs.org</span></span></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><a href="#cite_ref-5">↑</a> </span><span class="reference-text"><span class="ouvrage">« <a rel="nofollow" class="external text" href="http://www.gevent.org"><cite style="font-style:normal;">What is gevent? — gevent 1.3.0.dev0 documentation</cite></a> », sur <span class="italique">www.gevent.org</span></span></span>
</li>
</ol></div>
</div>
<div class="mw-heading mw-heading2"><h2 id="Liens_externes">Liens externes</h2></div>
<ul><li><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external text" href="http://www.stackless.com/">Page de Stackless Python</a></li>
<li><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20071001004937/http://members.verizon.net/olsongt/stackless/why_stackless.html">Introduction à la programmation concurrente avec Stackless Python</a></li></ul>
<div class="navbox-container" style="clear:both;">
</div>
<ul id="bandeau-portail" class="bandeau-portail"><li><span class="bandeau-portail-element"><span class="bandeau-portail-icone"><span class="noviewer" typeof="mw:File"></span></span> <span class="bandeau-portail-texte">Portail de la programmation informatique</span> </span></li> </ul></div><!--htdig_noindex--><div><div class="zim-footer">
Cet article est issu de <a class="external text" title="Dernière modification le 2025-05-11" href="https://fr.wikipedia.org/wiki/?title=Stackless_Python&oldid=225583123">Wikipédia</a>. Sauf mention contraire, le texte est disponible sous <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.fr">Creative Commons Attribution-Share Alike 4.0</a>. Des conditions supplémentaires peuvent s’appliquer aux fichiers multimédias.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
<script src="./_webp_/webpHandler.js"></script>
</body></html>